<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/11
 * Time: 17:07
 */
namespace core;

use core\request\Request;

class App
{
    public function run()
    {
        #路径  $_SERVER['REQUEST_URI']
        $req = Request::getInstance();
        debug_log($_SERVER['REMOTE_ADDR']
            .' '
            .($req->is_ajax()?'AJAX':$_SERVER['REQUEST_METHOD'])
            .' '.$_SERVER['REQUEST_URI']
            ,date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']));
        $req->run();
    }

    public function __destruct()
    {
        $utimes = explode(' ' ,microtime());
        $utime = $utimes[1]+$utimes[0];

        debug_log(date('Y-m-d H:i:s').' (runtime:'.sprintf('%.4f',($utime-$_SERVER['REQUEST_TIME_FLOAT'])*1000).'ms)'.'[内存消耗 '.(memory_get_usage()/1024).'KB]',' end_times ');
    }
}